// pages/route1/poster1/poster1.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    winWidth: '',
    winHeight: '',
    type_code: 0,
    ticket: null,
    ticketId: '',
    current:1,
    imgUrls: [
    ],
    indicatorDots: false,
    duration: 200,
    selticket:null
  },
  slide:function(e){
    console.log(e.detail.current)
    console.log(this.data.ticket)
    this.setData({
      current: e.detail.current+1,
      selticket: this.data.ticket[e.detail.current]
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });
    wx.request({
      url: app.globalData.rootUrl + '/api/ticket/get/',
      data: {
        productId: options.productId,
        orderId: options.orderId,
        session: options.session
      },
      success: function (res) {
        for (let item of res.data.data){
          item.qrcode = app.globalData.rootUrl + '/api/ticket/qrcode/get/?ticketId=' + item.ticketNo
        }
        that.setData({
          ticket: res.data.data,
          selticket: res.data.data[0]
        })
      }
    })
    wx.request({
      url: app.globalData.rootUrl + '/api/ticket/product/get/',
      data: {
        productId: options.productId,
      },
      success: function (res) {
        res.data.data[0].startDate = res.data.data[0].startDate.slice(0, 10).replace('-', '年').replace('-', '月')
console.log(res)
        that.setData({
          product: res.data.data[0]
        })

      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})